package info.moxingwang.spring.why;

import info.moxingwang.spring.why.service.Service1;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/*

- [Spring源码解析系列汇总](http://www.spring4all.com/article/16302)

 */

public class Application {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"applicationContext-bean.xml"}, false, null);
        ctx.addBeanFactoryPostProcessor(configurableListableBeanFactory -> {
            System.out.println(configurableListableBeanFactory);
        });
        ctx.addApplicationListener(new ApplicationListener<ApplicationEvent>() {
            @Override
            public void onApplicationEvent(ApplicationEvent event) {
                System.out.println( "event............." + event.getSource() );
            }
        });



        ctx.refresh();

        Service1 service1 = (Service1) ctx.getBean("service1");

        ctx.close();

        System.out.println("finished");
    }
}
